import pytest
from app import create_app
from extensions import db


@pytest.fixture
def client(app):
    yield app.test_client()


@pytest.fixture(scope='session', autouse=True)
def app():
    app = create_app('pytest')
    with app.app_context():
        yield app


@pytest.fixture(scope='session', autouse=True)
def create_db(app):
    assert app.config.get('TESTING'), '小伙子搞事情啊'
    db.create_all()
    yield
    db.session.remove()
    db.drop_all()
